function Enemy(type) {
	this.init = function() {
		this.body = document.createElement("div");
		switch(type) {
			case "small": {
				this.speed = 12;
				this.hp = 1;
				this.body.className = "enemy-small";
				this.dieimgs = ["plain1_die1.png","plain1_die2.png","plain1_die3.png"];
				new GameEngine().append(this);
				this.left(Math.min(new GameEngine().width() - this.width(), Math.random() * (new GameEngine().width()-this.width()) ))
				this.top(-this.height());
				break;
			}
			case "middle":{
				this.speed = 8;
				this.hp = 3;
				this.body.className = "enemy-middle";
				this.dieimgs = ["plain2_die1.png","plain2_die2.png","plain2_die3.png","plain2_die4.png"];
				new GameEngine().append(this);
				this.left(Math.min(new GameEngine().width() - this.width(), Math.random() * (new GameEngine().width()-this.width()) ))
				this.top(-this.height());
				break;
			}
			case "large":{
				this.speed = 4;
				this.hp = 8;
				this.body.className = "enemy-large";
				this.dieimgs = ["plain3_die1.png","plain3_die2.png","plain3_die3.png","plain3_die4.png","plain3_die5.png","plain3_die6.png"];
				new GameEngine().append(this);
				this.left(Math.min(new GameEngine().width() - this.width(), Math.random() * (new GameEngine().width()-this.width()) ))
				this.top(-this.height());
				break;
			}
		}
		return this;
	}
	this.left = function(val) {
		if(val || val == 0) {
			this.body.style.left = val + "px";
		}
		return this.body.offsetLeft;
	}
	this.top = function(val) {
		if(val || val == 0) {
			this.body.style.top = val + "px";
		}
		return this.body.offsetTop;
	}
	this.width = function() {
		return this.body.offsetWidth;
	}
	this.height = function() {
		return this.body.offsetHeight;
	}
	this.move = function() { //移动
		this.movetimer = setInterval(function() {
			this.top(this.top() + this.speed);
			if(this.top() > new GameEngine().height()) {
				clearInterval(this.movetimer); //关闭运动的定时器
				this.destroy();
			}
		}.bind(this), 30);
		return this;
	}
	this.hurt = function(){
		--this.hp==0 ? this.explode() : "";
	}
	this.explode = function() { //爆炸
		new GameEngine().enemes.delete(this); //将飞机从集合中清除
		//停止运动
		clearInterval(this.movetimer); //关闭运动的定时器
		var t = setInterval(function(){
			if(this.dieimgs.length == 0) {
				clearInterval(t);
				this.destroy();
			}
			this.body.style.background = "url(images/" + this.dieimgs.shift() +")";
		}.bind(this), 100);
	}
	this.fire = function() { //开火
		
	}
	this.destroy = function() {
		this.body.remove();
	}
}